]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
systemActions: Only do prefix matches
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 4 Nov 2018 23:21:26 +0000 (00:21 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 15 May 2019 17:20:21 +0000 (17:20 +0000)
Our search for system actions is currently inconsistent with searching
for applications: While we match terms anywhere within keywords, GIO
will only match at the beginning of words.

In order to get the same behavior, split keywords into single words
and only match terms at the beginning of a word.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/745

js/misc/systemActions.js

index aa79bfe54da2cc6abfbd4823a156b12021fdac6a..0a41964b36b37e0f34ba450dce267cecde294c1d 100644 (file)
@@ -88,42 +88,42 @@ const SystemActions = GObject.registerClass({
                             name: C_("search-result", "Power Off"),
                             iconName: 'system-shutdown-symbolic',
                             // Translators: A list of keywords that match the power-off action, separated by semicolons
-                            keywords: _("power off;shutdown;reboot;restart").split(';'),
+                            keywords: _("power off;shutdown;reboot;restart").split(/[; ]/),
                             available: false });
         this._actions.set(LOCK_SCREEN_ACTION_ID,
                           { // Translators: The name of the lock screen action in search
                             name: C_("search-result", "Lock Screen"),
                             iconName: 'system-lock-screen-symbolic',
                             // Translators: A list of keywords that match the lock screen action, separated by semicolons
-                            keywords: _("lock screen").split(';'),
+                            keywords: _("lock screen").split(/[; ]/),
                             available: false });
         this._actions.set(LOGOUT_ACTION_ID,
                           { // Translators: The name of the logout action in search
                             name: C_("search-result", "Log Out"),
                             iconName: 'application-exit-symbolic',
                             // Translators: A list of keywords that match the logout action, separated by semicolons
-                            keywords: _("logout;sign off").split(';'),
+                            keywords: _("logout;log out;sign off").split(/[; ]/),
                             available: false });
         this._actions.set(SUSPEND_ACTION_ID,
                           { // Translators: The name of the suspend action in search
                             name: C_("search-result", "Suspend"),
                             iconName: 'media-playback-pause-symbolic',
                             // Translators: A list of keywords that match the suspend action, separated by semicolons
-                            keywords: _("suspend;sleep").split(';'),
+                            keywords: _("suspend;sleep").split(/[; ]/),
                             available: false });
         this._actions.set(SWITCH_USER_ACTION_ID,
                           { // Translators: The name of the switch user action in search
                             name: C_("search-result", "Switch User"),
                             iconName: 'system-switch-user-symbolic',
                             // Translators: A list of keywords that match the switch user action, separated by semicolons
-                            keywords: _("switch user").split(';'),
+                            keywords: _("switch user").split(/[; ]/),
                             available: false });
         this._actions.set(LOCK_ORIENTATION_ACTION_ID,
                           { // Translators: The name of the lock orientation action in search
                             name: C_("search-result", "Lock Orientation"),
                             iconName: '',
                             // Translators: A list of keywords that match the lock orientation action, separated by semicolons
-                            keywords: _("lock orientation;screen;rotation").split(';'),
+                            keywords: _("lock orientation;screen;rotation").split(/[; ]/),
                             available: false });
 
         this._loginScreenSettings = new Gio.Settings({ schema_id: LOGIN_SCREEN_SCHEMA });
@@ -262,7 +262,7 @@ const SystemActions = GObject.registerClass({
         let results = [];
 
         for (let [key, {available, keywords}] of this._actions)
-            if (available && terms.every(t => keywords.some(k => (k.indexOf(t) >= 0))))
+            if (available && terms.every(t => keywords.some(k => k.startsWith(t))))
                 results.push(key);
 
         return results;